﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace iLangl
{
	public class ErrorManager
	{
		public static bool IsPresentSeverity(IList<IError> errors, eSeverity severity)
		{
			foreach (IError error in errors)
			{
				if (error.Severity == severity)
					return true;
			}
			return false;
		}

		public static ErrorStatistic GetStatistic(IList<IError> errors)
		{
			ErrorStatistic result = new ErrorStatistic();

			if (errors == null)
				return result;

			foreach(IError error in errors)
			{
				switch(error.Severity)
				{
					case eSeverity.Low:
						result.LowErrorsCount++;
						break;
					case eSeverity.Medium:
						result.MediumErrorsCount++;
						break;
					case eSeverity.High :
						result.HighErrorsCount++;
						break;
					case eSeverity.Critical:
						result.CriticalErrorsCount++;
						break;
				}

			}
			return result;
		}

	}
}
